import Vue from "vue"
import Router from "vue-router"
const _import = require("./_import_" + process.env.NODE_ENV)
import Home from "@c/Home.vue"
import Container from "@c/Container.vue"
import App from "@/App.vue"
import bus from "@/utils/eventBus"

Vue.use(Router)

const routes = [
  {
    path: "/",
    component: App,
    redirect: {
      name: "login"
    },
    children: [
      {
        path: "/login",
        name: "login",
        component: _import("login/Login")
      },
      {
        path: "/remember",
        name: "loginTip",
        component: _import("login/Remember")
      },
      {
        path: "/register",
        name: "register",
        component: _import("login/Register")
      },
      {
        path: "/home",
        name: "home",
        component: Home,
        redirect: {
          name: "homePage"
        },
        children: [
          {
            path: "/home/homePage",
            name: "homePage",
            component: _import("home/HomePage"),
            meta: {
              keepAlive: true
            }
          },
          {
            path: "/home/workstation",
            name: "workstation",
            component: _import("workstation/WorkStation")
          },
          {
            path: "/home/integral",
            name: "integral",
            component: _import("integral/integral")
          },
          {
            path: "/home/mine",
            name: "mine",
            component: _import("mine/Mine")
          }
        ]
      },
      {
        path: "/integral",
        name: "integral",
        component: Container,
        children: [
          //积分添加
          {
            path: "/integral/integralAdd",
            name: "integralAdd",
            component: _import("integral/integralAdd")
          },
          //减积分
          {
            path: "/integral/integralCut",
            name: "integralCut",
            component: _import("integral/integralCut")
          },
          //申报记录
          {
            path: "/integral/declareRecord",
            name: "declareRecord",
            component: _import("integral/declareRecord"),
            meta: {
              keepAlive: true,
              isBack: false
            }
          },
          //积分申报
          {
            path: "/integral/integralDeclare",
            name: "integralDeclare",
            component: _import("integral/integralDeclare")
            // meta: {
            //   keepAlive: true
            // }
          },
          //积分申报详情
          {
            path: "/integral/integralDeclareDetails",
            name: "integralDeclareDetails",
            component: _import("integral/integralDeclareDetails")
          },
          //我的积分
          {
            path: "/integral/myIntegral",
            name: "myIntegral",
            component: _import("integral/myIntegral")
          },
          // 积分简介
          {
            path: "/integral/integralIntroduced",
            name: "integralIntroduced",
            component: _import("integral/integralIntroduced"),
            meta: {
              keepAlive: true
            }
          },
          // 首页积分栏
          {
            path: "/integral/publicBar",
            name: "publicBar",
            component: _import("integral/publicBar")
          },
          // 首页积分栏详情
          {
            path: "/integral/publicBarDetails",
            name: "publicBarDetails",
            component: _import("integral/publicBarDetails")
          },
          // 栋楼长审核
          {
            path: "/integral/editEeclareRecord/:data",
            name: "editEeclareRecord",
            component: _import("integral/editEeclareRecord")
          }
        ]
      },
      {
        path: "/work",
        name: "work",
        component: Container,
        children: [
          {
            path: "/home/MoreServes",
            name: "moreServes",
            component: _import("home/MoreServes"),
            meta: {
              keepAlive: true
            }
          },
          {
            path: "/home/NoticeDetails",
            name: "noticeDetails",
            component: _import("home/NoticeDetails")
          },
          {
            path: "/home/DynamicDetails",
            name: "dynamicDetails",
            component: _import("home/DynamicDetails")
          },
          {
            path: "/home/DynamicMore",
            name: "dynamicMore",
            component: _import("home/DynamicMore")
          },
          {
            path: "/home/neighborhoodList",
            name: "neighborhoodList",
            component: _import("home/neighborhoodList")
          },
          {
            path: "/home/CommunityLocation",
            name: "communityLocation",
            component: _import("home/CommunityLocation")
          },
          // 物业服务
          {
            path: "/work/lifePay", // 物业缴费
            name: "lifePay",
            component: _import("workstation/propertyService/LifePay")
          },
          {
            path: "/work/immediatePay", // 缴费记录
            name: "immediatePay",
            component: _import("workstation/propertyService/immediatePay")
          },
          {
            path: "/work/newPay", // 新增缴费
            name: "newPay",
            component: _import("workstation/propertyService/newPay")
          },
          {
            path: "/work/payHistory", // 缴费记录
            name: "payHistory",
            component: _import("workstation/propertyService/payHistory")
          },
          {
            path: "/work/houseNumberManage", // 户号管理
            name: "houseNumberManage",
            component: _import("workstation/propertyService/houseNumberManage")
          },
          {
            path: "/work/propertyRepair",
            name: "propertyRepair",
            component: _import("workstation/propertyService/propertyRepair")
          },
          {
            path: "/work/myRepair",
            name: "myRepair",
            component: _import("workstation/propertyService/myRepair")
          },
          {
            path: "/work/publicFacilities",
            name: "publicFacilities",
            component: _import("workstation/propertyService/publicFacilities")
          },
          {
            path: "/work/facilityManage",
            name: "facilityManage",
            component: _import("workstation/propertyService/facilityManage")
          },
          {
            path: "/work/facilityRepair",
            name: "facilityRepair",
            component: _import("workstation/propertyService/facilityRepair")
          },
          {
            path: "/work/basicFacts",
            name: "basicFacts",
            component: _import("workstation/propertyService/basicFacts")
          },
          {
            path: "/work/intelligentAccessControl",
            name: "intelligentAccessControl",
            component: _import(
              "workstation/propertyService/intelligentAccessControl"
            )
          },
          {
            path: "/work/visitorRecord",
            name: "visitorRecord",
            component: _import("workstation/propertyService/visitorRecord")
          },
          {
            path: "/work/applyParkingPlace",
            name: "applyParkingPlace",
            component: _import("workstation/propertyService/applyParkingPlace")
          },
          // 生活服务
          {
            path: "/work/expressService",
            name: "expressService",
            component: _import("workstation/lifeService/expressService")
          },
          {
            path: "/work/surroundingStore",
            name: "surroundingStore",
            component: _import("workstation/lifeService/surroundingStore")
          },
          // 社区生活
          {
            path: "/work/communityActivity",
            name: "communityActivity",
            component: _import("workstation/communityLife/communityActivity")
          },
          {
            path: "/work/communityDynamics",
            name: "communityDynamics",
            component: _import("workstation/communityLife/communityDynamics")
          },
          {
            path: "/work/votingElections",
            name: "votingElections",
            component: _import("workstation/communityLife/votingElections")
          },
          // 公共服务
          {
            path: "/work/govAffairs", // 政务办事
            name: "govAffairs",
            component: _import("workstation/publicService/govAffairs")
          },
          {
            path: "/work/hotInformationDetails", // 热点资讯详情
            name: "hotInformationDetails",
            component: _import(
              "workstation/publicService/govAffairs/HotInformationDetails"
            )
          },
          {
            path: "/work/serviceInfo", // 服务指南
            name: "serviceInfo",
            component: _import(
              "workstation/publicService/govAffairs/serviceInfo/serviceInfo"
            )
          },
          {
            path: "/work/onlineService", // 在线办事
            name: "onlineService",
            component: _import(
              "workstation/publicService/govAffairs/onlineService/onlineService"
            )
          },
          {
            path: "/work/serviceName", // 在线办事子项列表
            name: "serviceName",
            component: _import(
              "workstation/publicService/govAffairs/onlineService/serviceName"
            )
          },
          {
            path: "/work/todoMatter", // 事项办理
            name: "todoMatter",
            component: _import(
              "workstation/publicService/govAffairs/onlineService/todoMatter"
            )
          },
          {
            path: "/work/detailPage", // 事项详情
            name: "detailPage",
            component: _import(
              "workstation/publicService/govAffairs/workSchedule/detailPage"
            )
          },
          {
            path: "/work/editPage", // 事件修改
            name: "editPage",
            component: _import(
              "workstation/publicService/govAffairs/workSchedule/editPage"
            )
          },
          {
            path: "/work/applyPage", // 事项办理申请
            name: "applyPage",
            component: _import(
              "workstation/publicService/govAffairs/onlineService/applyPage"
            )
          },
          {
            path: "/work/workSchedule", // 办件进度
            name: "workSchedule",
            component: _import(
              "workstation/publicService/govAffairs/workSchedule/workSchedule"
            )
          },
          {
            path: "/work/matterStatus", // 办件状态页面
            name: "matterStatus",
            component: _import(
              "workstation/publicService/govAffairs/workSchedule/matterStatus"
            )
          },
          {
            path: "/work/myExpress", // 我的快递
            name: "myExpress",
            component: _import(
              "workstation/publicService/govAffairs/myExpress/myExpress"
            )
          },
          {
            path: "/work/massService",
            name: "massService",
            component: _import("workstation/publicService/massService")
          },
          {
            path: "/work/oldAgeService",
            name: "oldAgeService",
            component: _import("workstation/publicService/oldAgeService")
          },
          //养老服务
          {
            path: "/work/liveNursingService",
            name: "liveNursingService",
            component: _import(
              "workstation/publicService/oldAgeBranch/liveNursingService"
            )
          },
          {
            path: "/work/oldAgeFiles",
            name: "oldAgeFiles",
            component: _import(
              "workstation/publicService/oldAgeBranch/oldAgeFiles"
            )
          },
          {
            path: "/work/qualityService",
            name: "qualityService",
            component: _import(
              "workstation/publicService/oldAgeBranch/qualityService"
            )
          },
          {
            path: "/work/searchService",
            name: "searchService",
            component: _import(
              "workstation/publicService/oldAgeBranch/searchService"
            )
          },
          {
            path: "/work/patrolList",
            name: "patrolList",
            component: _import(
              "workstation/publicService/oldAgeBranch/patrolList"
            )
          },
          {
            path: "/work/oldAgeFileDetail",
            name: "oldAgeFileDetail",
            component: _import(
              "workstation/publicService/oldAgeBranch/oldAgeFileDetail"
            )
          },
          {
            path: "/work/patrolFeedback",
            name: "patrolFeedback",
            component: _import(
              "workstation/publicService/oldAgeBranch/patrolFeedback"
            )
          },
          {
            path: "/work/editFeedback",
            name: "editFeedback",
            component: _import(
              "workstation/publicService/oldAgeBranch/editFeedback"
            )
          },
          //养老资讯
          {
            path: "/work/oldNewsMore",
            name: "oldNewsMore",
            component: _import(
              "workstation/publicService/oldAgeBranch/oldNewsMore"
            )
          },
          {
            path: "/work/oldNewsViewMore",
            name: "oldNewsViewMore",
            component: _import(
              "workstation/publicService/oldAgeBranch/oldNewsViewMore"
            )
          },
          {
            path: "/work/oldNewsDetails",
            name: "oldNewsDetails",
            component: _import(
              "workstation/publicService/oldAgeBranch/oldNewsDetails"
            )
          },
          {
            path: "/work/orderRegister",
            name: "orderRegister",
            component: _import("workstation/publicService/orderRegister")
          },
          {
            path: "/work/SOSHelp",
            name: "SOSHelp",
            component: _import("workstation/publicService/SOSHelp")
          },
          {
            path: "/work/streetCommittee",
            name: "streetCommittee",
            component: _import("workstation/publicService/streetCommittee")
          },
          {
            path: "/person/feedBack",
            name: "feedBack",
            component: _import("mine/feedback/feedBack")
          },
          //就业培训
          {
            path: "/work/employmentTraining/employmentTraining",
            name: "employmentTraining",
            component: _import(
              "workstation/publicService/employmentTraining/employmentTraining"
            )
          },
          {
            path: "/work/employmentTraining/jobConditions",
            name: "jobConditions",
            component: _import(
              "workstation/publicService/employmentTraining/jobConditions"
            )
          },
          {
            path: "/work/employmentTraining/workPlace",
            name: "workPlace",
            component: _import(
              "workstation/publicService/employmentTraining/workPlace"
            )
          },
          {
            path: "/work/employmentTraining/companyDetails",
            name: "companyDetails",
            component: _import(
              "workstation/publicService/employmentTraining/companyDetails"
            )
          },
          {
            path: "/work/employmentTraining/jobDetails",
            name: "jobDetails",
            component: _import(
              "workstation/publicService/employmentTraining/jobDetails"
            )
          },
          {
            path: "/work/employmentTraining/jobRecruitment",
            name: "jobRecruitment",
            component: _import(
              "workstation/publicService/employmentTraining/jobRecruitment"
            )
          },
          {
            path: "/work/employmentTraining/skillsTraining",
            name: "skillsTraining",
            component: _import(
              "workstation/publicService/employmentTraining/skillsTraining"
            )
          },
          {
            path: "/work/employmentTraining/skillTrainingDetails",
            name: "skillTrainingDetails",
            component: _import(
              "workstation/publicService/employmentTraining/skillTrainingDetails"
            )
          },
          //我的简历
          {
            path: "/work/myResume/myResume",
            name: "myResume",
            component: _import("workstation/publicService/myResume/myResume")
          },
          {
            path: "/work/myResume/addResume",
            name: "addResume",
            component: _import("workstation/publicService/myResume/addResume")
          },
          {
            path: "/work/myResume/myDelivery",
            name: "myDelivery",
            component: _import("workstation/publicService/myResume/myDelivery")
          },
          {
            path: "/work/myResume/myResumeAdd",
            name: "myResumeAdd",
            component: _import("workstation/publicService/myResume/myResumeAdd")
          },
          {
            path: "/work/myResume/updateHeadImg",
            name: "updateHeadImg",
            component: _import(
              "workstation/publicService/myResume/updateHeadImg"
            )
          },
          // {
          //   path: '/work/myResume/myResume',
          //   name: 'myResume',
          //   component: _import('workstation/publicService/myResume/myResume')
          // },
          //社区医疗
          {
            path: "/work/communityHealth/communityDoctor",
            name: "communityDoctor",
            component: _import(
              "workstation/publicService/communityHealth/communityDoctor"
            )
          },
          {
            path: "/work/communityHealth/communityHealth",
            name: "communityHealth",
            component: _import(
              "workstation/publicService/communityHealth/communityHealth"
            )
          },
          {
            path: "/work/communityHealth/communityPharmacy",
            name: "communityPharmacy",
            component: _import(
              "workstation/publicService/communityHealth/communityPharmacy"
            )
          },
          {
            path: "/work/communityHealth/fileBinding",
            name: "fileBinding",
            component: _import(
              "workstation/publicService/communityHealth/fileBinding"
            )
          },
          {
            path: "/work/communityHealth/visitFile",
            name: "visitFile",
            component: _import(
              "workstation/publicService/communityHealth/visitFile"
            )
          },
          {
            path: "/work/communityHealth/healthInformation",
            name: "healthInformation",
            component: _import(
              "workstation/publicService/communityHealth/healthInformation"
            )
          },
          {
            path: "/work/communityHealth/healthInformationDetails",
            name: "healthInformationDetails",
            component: _import(
              "workstation/publicService/communityHealth/healthInformationDetails"
            )
          },
          {
            path: "/work/communityHealth/medicalRecord",
            name: "medicalRecord",
            component: _import(
              "workstation/publicService/communityHealth/medicalRecord"
            )
          },
          {
            path: "/work/communityHealth/myConsultation",
            name: "myConsultation",
            component: _import(
              "workstation/publicService/communityHealth/myConsultation"
            )
          },
          {
            path: "/work/communityHealth/toConsultation",
            name: "toConsultation",
            component: _import(
              "workstation/publicService/communityHealth/toConsultation"
            )
          },
          // {
          //   path: '/work/communityHealth/visitFile',
          //   name: 'visitFile',
          //   component: _import('workstation/publicService/communityHealth/visitFile')
          // },
          //特色服务
          {
            path: "/work/specialService/school",
            name: "school",
            component: _import(
              "workstation/publicService/specialService/school"
            )
          },
          {
            path: "/work/specialService/applicationConfim",
            name: "applicationConfim",
            component: _import(
              "workstation/publicService/specialService/applicationConfim"
            )
          },
          {
            path: "/work/specialService/myServiceApplication",
            name: "myServiceApplication",
            component: _import(
              "workstation/publicService/specialService/myServiceApplication"
            )
          },
          {
            path: "/work/specialService/applicationDetails",
            name: "applicationDetails",
            component: _import(
              "workstation/publicService/specialService/applicationDetails"
            )
          }
        ]
      },
      {
        path: "/person",
        name: "person",
        component: Container,
        children: [
          //个人信息详情，修改
          {
            path: "/person/personaldetail",
            name: "personalInformationDetails",
            component: _import("mine/personaldetail/personalInformationDetails")
          },
          {
            path: "/person/nickname",
            name: "nickname",
            component: _import("mine/personaldetail/nickname")
          },
          {
            path: "/person/avatar",
            name: "avatar",
            component: _import("mine/personaldetail/avatar")
          },
          {
            path: "/person/gender",
            name: "gender",
            component: _import("mine/personaldetail/gender")
          },
          //意见反馈
          {
            path: "/person/feedback",
            name: "feedback",
            component: _import("mine/feedback/feedBack")
          },
          //安全中心
          {
            path: "/person/bindPhoneNumber",
            name: "bindPhoneNumber",
            component: _import("mine/securitycenter/bindPhoneNumber")
          },
          {
            path: "/person/modifyPassword",
            name: "modifyPassword",
            component: _import("mine/securitycenter/modifyPassword")
          },
          {
            path: "/person/modifyPhoneNumber",
            name: "modifyPhoneNumber",
            component: _import("mine/securitycenter/modifyPhoneNumber")
          },
          {
            path: "/person/paintNewPassword",
            name: "paintNewPassword",
            component: _import("mine/securitycenter/paintNewPassword")
          },
          {
            path: "/person/securityCenter",
            name: "securityCenter",
            component: _import("mine/securitycenter/securityCenter")
          },
          //系统设置
          {
            path: "/person/concerning",
            name: "concerning",
            component: _import("mine/systemsettings/concerning")
          },
          {
            path: "/person/features",
            name: "features",
            component: _import("mine/systemsettings/features")
          },
          {
            path: "/person/systemSettings",
            name: "systemSettings",
            component: _import("mine/systemsettings/systemSettings")
          },
          {
            path: "/person/updateComponent",
            name: "updateComponent",
            component: _import("mine/systemsettings/updateComponent")
          },
          // 我的房屋
          {
            path: "/person/myHouses",
            name: "myHouses",
            component: _import("mine/myHouses/MyHouses")
            //  meta: {
            //    keepAlive: true
            //  }
          },
          {
            path: "/person/boundHouses",
            name: "boundHouses",
            component: _import("mine/myHouses/BoundHouses"),
            meta: {
              keepAlive: true,
              isBack: false
            }
          },
          {
            path: "/person/houseList",
            name: "houseList",
            component: _import("mine/myHouses/HouseList")
          },
          {
            path: "/person/houseDetail",
            name: "houseDetail",
            component: _import("mine/myHouses/HouseDetail")
          }
        ]
      }
    ]
  }
]

const router = new Router({
  routes
})

export function hook() {
  router.beforeEach((to, from, next) => {
    // 缓存返回的界面
    if (to.name == "homePage" && from.name != "dynamicDetails") {
      bus.$emit("login")
      next()
    }
    if (!to.meta.skipAuth) {
      next()
    } else {
      next()
    }
  })
}

export default router
